package com.yhgarden.bbs.controller.common;

import com.yhgarden.bbs.service.api.common.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = {"/common/websocket","*/common/websocket"})
public class WebsocketController {

    @Autowired
    private WebSocketService webSocketService;

    @RequestMapping("/sendAllWebSocket")
    public String test() {
        webSocketService.sendAllMessage("清晨起来打开窗，心情美美哒~");
        return "websocket群体发送！";
    }

    @RequestMapping("/sendOneWebSocket/{userId}")
    public String sendOneWebSocket(@PathVariable("userId") String userId) {
        webSocketService.sendOneMessage(userId, "只要你乖给你买条gai！");
        return "websocket单人发送";
    }
}